﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace LotteryBO
{
    class Agent
    {
        iDAC dac = DACFactory.GetDAC();
        private long _agent_code = -99;
        private string _agent_name = "";
        private string _mail_id = "";
        private long _mobile_no = -99;
        private bool _isdeleted = false;
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }
        public long agent_code
        {
            get
            {
                return _agent_code;
            }
            set
            {
                _agent_code = value;
            }
        }
        public string agent_name
        {
            get
            {
                return _agent_name;
            }
            set
            {
                _agent_name = value;
            }
        }
        public string mail_id
        {
            get
            {
                return _mail_id;
            }
            set
            {
               _mail_id = value;
            }
        }
        public long mobile_no
        {
            get
            {
                return _mobile_no;
            }
            set
            {
                _mobile_no = value;
            }
        }
         public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = dac.Parameter("@agent_code", agent_code, DbType.Int64, ParameterDirection.Input);                
                DbParameter dbparam1 = dac.Parameter("@agent_name", agent_name, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = dac.Parameter("@mail_id",mail_id , DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = dac.Parameter("@mobile_no",mobile_no, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = dac.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] {dbparam0,dbparam1, dbparam2, dbparam3, dbparam4 };
                return dac.Save("Agents_list_save", dbparamcall);
            }
            catch(Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
         public DataTable GetRecords(long agent_code, string agent_name, string mail_id, long mobile_no, bool isdeleted, string andor)
        {
            try
            {
                DbParameter dbparam0 = dac.Parameter("@agent_code", agent_code, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = dac.Parameter("@agent_name", agent_name, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = dac.Parameter("@mail_id", mail_id, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = dac.Parameter("@mobile_no", mobile_no, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam4 = dac.Parameter("@isdeleted", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4 };
                DataTable dt1 = dac.Select("Agent_list_get", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
